<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><link rel="stylesheet" href="file:////usr/local/matlabr2008b/toolbox/matlab/codetools/matlab-report-styles.css" type="text/css" /><title>Function details for ConstructHMatrix</title><link rel="stylesheet" href="file:////usr/local/matlabr2008b/toolbox/matlab/codetools/matlab-report-styles.css" type="text/css" /></head><body bgcolor="#F8F8F8"><strong>This is a static copy of a profile report</strong><p><a href="file0.html">Home</a><p><span style="font-size:14pt; background:#FFE4B0">ConstructHMatrix (1 call, 241.019 sec)</span><br/><i>Generated 22-Nov-2009 08:26:56 using cpu time.</i><br/>M-function in file /home1/jianfeng/project/hmatinv/trunk/2DHMAT/ConstructHMatrix.m<br/>Copy to new window for comparing multiple runs<div class="grayline"/><div class="grayline"/><strong>Parents</strong> (calling functions)<br/> No parent <div class="grayline"/><strong>Lines where the most time was spent</strong><br/> <p><table border=0 cellspacing=0 cellpadding=6><tr><td class="td-linebottomrt" bgcolor="#F0F0F0">Line Number</td><td class="td-linebottomrt" bgcolor="#F0F0F0">Code</td><td class="td-linebottomrt" bgcolor="#F0F0F0">Calls</td><td class="td-linebottomrt" bgcolor="#F0F0F0">Total Time</td><td class="td-linebottomrt" bgcolor="#F0F0F0">% Time</td><td class="td-linebottomrt" bgcolor="#F0F0F0">Time Plot</td></tr><tr><td class="td-linebottomrt"><a href="#Line82">82</a></td><td class="td-linebottomrt"><pre>TempMatRes = KernelApply( N, r...</pre></td><td class="td-linebottomrt">208</td><td class="td-linebottomrt">151.314 s</td><td class="td-linebottomrt" class="td-linebottomrt">62.8%</td><td class="td-linebottomrt"><img src="file:////usr/local/matlabr2008b/toolbox/matlab/codetools/private/one-pixel.gif" width=63 height=10></td></tr><tr><td class="td-linebottomrt"><a href="#Line85">85</a></td><td class="td-linebottomrt"><pre>TempMatRKRes = RKTreeApply( Sa...</pre></td><td class="td-linebottomrt">208</td><td class="td-linebottomrt">37.020 s</td><td class="td-linebottomrt" class="td-linebottomrt">15.4%</td><td class="td-linebottomrt"><img src="file:////usr/local/matlabr2008b/toolbox/matlab/codetools/private/one-pixel.gif" width=15 height=10></td></tr><tr><td class="td-linebottomrt"><a href="#Line398">398</a></td><td class="td-linebottomrt"><pre>TempMatRes = KernelApply( N, r...</pre></td><td class="td-linebottomrt">1</td><td class="td-linebottomrt">14.553 s</td><td class="td-linebottomrt" class="td-linebottomrt">6.0%</td><td class="td-linebottomrt"><img src="file:////usr/local/matlabr2008b/toolbox/matlab/codetools/private/one-pixel.gif" width=6 height=10></td></tr><tr><td class="td-linebottomrt"><a href="#Line101">101</a></td><td class="td-linebottomrt"><pre>[TempU, TempS, TempW ] = svd( ...</pre></td><td class="td-linebottomrt">36400</td><td class="td-linebottomrt">7.061 s</td><td class="td-linebottomrt" class="td-linebottomrt">2.9%</td><td class="td-linebottomrt"><img src="file:////usr/local/matlabr2008b/toolbox/matlab/codetools/private/one-pixel.gif" width=3 height=10></td></tr><tr><td class="td-linebottomrt"><a href="#Line137">137</a></td><td class="td-linebottomrt"><pre>RKTree{iLevel}.RKBlockM{iRKBlo...</pre></td><td class="td-linebottomrt">18200</td><td class="td-linebottomrt">6.290 s</td><td class="td-linebottomrt" class="td-linebottomrt">2.6%</td><td class="td-linebottomrt"><img src="file:////usr/local/matlabr2008b/toolbox/matlab/codetools/private/one-pixel.gif" width=3 height=10></td></tr><tr><td class="td-linebottomrt">All other lines</td><td class="td-linebottomrt">&nbsp;</td><td class="td-linebottomrt">&nbsp;</td><td class="td-linebottomrt">24.780 s</td><td class="td-linebottomrt">10.3%</td><td class="td-linebottomrt"><img src="file:////usr/local/matlabr2008b/toolbox/matlab/codetools/private/one-pixel.gif" width=10 height=10></td></tr><tr><td class="td-linebottomrt" bgcolor="#F0F0F0">Totals</td><td class="td-linebottomrt" bgcolor="#F0F0F0">&nbsp;</td><td class="td-linebottomrt" bgcolor="#F0F0F0">&nbsp;</td><td class="td-linebottomrt" bgcolor="#F0F0F0">241.019 s</td><td class="td-linebottomrt" bgcolor="#F0F0F0">100%</td><td class="td-linebottomrt" bgcolor="#F0F0F0">&nbsp;</td></tr></table><div class="grayline"/><b>Children</b> (called functions)<br/><p><table border=0 cellspacing=0 cellpadding=6><tr><td class="td-linebottomrt" bgcolor="#F0F0F0">Function Name</td><td class="td-linebottomrt" bgcolor="#F0F0F0">Function Type</td><td class="td-linebottomrt" bgcolor="#F0F0F0">Calls</td><td class="td-linebottomrt" bgcolor="#F0F0F0">Total Time</td><td class="td-linebottomrt" bgcolor="#F0F0F0">% Time</td><td class="td-linebottomrt" bgcolor="#F0F0F0">Time Plot</td></tr><tr><td class="td-linebottomrt"><a href="file6.html">KernelApply</a></td><td class="td-linebottomrt">M-function</td><td class="td-linebottomrt">209</td><td class="td-linebottomrt">165.868 s</td><td class="td-linebottomrt">68.8%</td><td class="td-linebottomrt"><img src="file:////usr/local/matlabr2008b/toolbox/matlab/codetools/private/one-pixel.gif" width=69 height=10></td></tr><tr><td class="td-linebottomrt"><a href="file9.html">RKTreeApply</a></td><td class="td-linebottomrt">M-function</td><td class="td-linebottomrt">209</td><td class="td-linebottomrt">42.569 s</td><td class="td-linebottomrt">17.7%</td><td class="td-linebottomrt"><img src="file:////usr/local/matlabr2008b/toolbox/matlab/codetools/private/one-pixel.gif" width=18 height=10></td></tr><tr><td class="td-linebottomrt"><a href="file10.html">pinv</a></td><td class="td-linebottomrt">M-function</td><td class="td-linebottomrt">36400</td><td class="td-linebottomrt">5.018 s</td><td class="td-linebottomrt">2.1%</td><td class="td-linebottomrt"><img src="file:////usr/local/matlabr2008b/toolbox/matlab/codetools/private/one-pixel.gif" width=2 height=10></td></tr><tr><td class="td-linebottomrt"><a href="file4.html">ConstructSampleList</a></td><td class="td-linebottomrt">M-function</td><td class="td-linebottomrt">1</td><td class="td-linebottomrt">2.774 s</td><td class="td-linebottomrt">1.2%</td><td class="td-linebottomrt"><img src="file:////usr/local/matlabr2008b/toolbox/matlab/codetools/private/one-pixel.gif" width=1 height=10></td></tr><tr><td class="td-linebottomrt"><a href="file5.html">ConstructRKTree</a></td><td class="td-linebottomrt">M-function</td><td class="td-linebottomrt">1</td><td class="td-linebottomrt">1.833 s</td><td class="td-linebottomrt">0.8%</td><td class="td-linebottomrt"><img src="file:////usr/local/matlabr2008b/toolbox/matlab/codetools/private/one-pixel.gif" width=1 height=10></td></tr><tr><td class="td-linebottomrt"><a href="file11.html">repmat</a></td><td class="td-linebottomrt">M-function</td><td class="td-linebottomrt">4096</td><td class="td-linebottomrt">0.110 s</td><td class="td-linebottomrt">0.0%</td><td class="td-linebottomrt"><img src="file:////usr/local/matlabr2008b/toolbox/matlab/codetools/private/one-pixel.gif" width=0 height=10></td></tr><tr><td class="td-linebottomrt">Self time (built-ins, overhead, etc.)</td><td class="td-linebottomrt">&nbsp;</td><td class="td-linebottomrt">&nbsp;</td><td class="td-linebottomrt">22.847 s</td><td class="td-linebottomrt">9.5%</td><td class="td-linebottomrt"><img src="file:////usr/local/matlabr2008b/toolbox/matlab/codetools/private/one-pixel.gif" width=9 height=10></td></tr><tr><td class="td-linebottomrt" bgcolor="#F0F0F0">Totals</td><td class="td-linebottomrt" bgcolor="#F0F0F0">&nbsp;</td><td class="td-linebottomrt" bgcolor="#F0F0F0">&nbsp;</td><td class="td-linebottomrt" bgcolor="#F0F0F0">241.019 s</td><td class="td-linebottomrt" bgcolor="#F0F0F0">100%</td><td class="td-linebottomrt" bgcolor="#F0F0F0">&nbsp;</td></tr></table><div class="grayline"/><strong>M-Lint results</strong><br/><table border=0 cellspacing=0 cellpadding=6><tr><td class="td-linebottomrt" bgcolor="#F0F0F0">Line number</td><td class="td-linebottomrt" bgcolor="#F0F0F0">Message</td></tr><tr><td class="td-linebottomrt"><a href="#Line3">3</a></td><td class="td-linebottomrt"><span class="mono">The value assigned here to variable 'solvetime' might be unused.</span></td></tr><tr><td class="td-linebottomrt"><a href="#Line4">4</a></td><td class="td-linebottomrt"><span class="mono">The value assigned here to variable 'RKmulttime' might be unused.</span></td></tr><tr><td class="td-linebottomrt"><a href="#Line9">9</a></td><td class="td-linebottomrt"><span class="mono">The value assigned here to variable 'nWidthTop' might be unused.</span></td></tr><tr><td class="td-linebottomrt"><a href="#Line101">101</a></td><td class="td-linebottomrt"><span class="mono">The value assigned here to variable 'TempW' might be unused.</span></td></tr><tr><td class="td-linebottomrt"><a href="#Line103">103</a></td><td class="td-linebottomrt"><span class="mono">Use FIND with the new 'first' or 'last' option.</span></td></tr><tr><td class="td-linebottomrt"><a href="#Line178">178</a></td><td class="td-linebottomrt"><span class="mono">'UAll' might be growing inside a loop. Consider preallocating for speed.</span></td></tr><tr><td class="td-linebottomrt"><a href="#Line181">181</a></td><td class="td-linebottomrt"><span class="mono">'UAll' might be growing inside a loop. Consider preallocating for speed.</span></td></tr><tr><td class="td-linebottomrt"><a href="#Line187">187</a></td><td class="td-linebottomrt"><span class="mono">The value assigned here to variable 'TempV' might be unused.</span></td></tr><tr><td class="td-linebottomrt"><a href="#Line192">192</a></td><td class="td-linebottomrt"><span class="mono">Use FIND with the new 'first' or 'last' option.</span></td></tr><tr><td class="td-linebottomrt"><a href="#Line272">272</a></td><td class="td-linebottomrt"><span class="mono">FOR might not be aligned with its matching END (line 277).</span></td></tr><tr><td class="td-linebottomrt"><a href="#Line342">342</a></td><td class="td-linebottomrt"><span class="mono">The value assigned here to variable 'nSampleDiag' might be unused.</span></td></tr><tr><td class="td-linebottomrt"><a href="#Line380">380</a></td><td class="td-linebottomrt"><span class="mono">The value assigned here to variable 'TempMatRes' might be unused.</span></td></tr><tr><td class="td-linebottomrt"><a href="#Line381">381</a></td><td class="td-linebottomrt"><span class="mono">The value assigned here to variable 'TempMatRKRes' might be unused.</span></td></tr><tr><td class="td-linebottomrt"><a href="#Line424">424</a></td><td class="td-linebottomrt"><span class="mono">The value assigned here to variable 'TempMatRes' might be unused.</span></td></tr><tr><td class="td-linebottomrt"><a href="#Line425">425</a></td><td class="td-linebottomrt"><span class="mono">The value assigned here to variable 'TempMatRKRes' might be unused.</span></td></tr></table><div class="grayline"/><strong>Coverage results</strong><br/>[ Show coverage for parent directory ]<br/><table border=0 cellspacing=0 cellpadding=6><tr><td class="td-linebottomrt" bgcolor="#F0F0F0">Total lines in function</td><td class="td-linebottomrt">433</td></tr><tr><td class="td-linebottomrt" bgcolor="#F0F0F0">Non-code lines (comments, blank lines)</td><td class="td-linebottomrt">216</td></tr><tr><td class="td-linebottomrt" bgcolor="#F0F0F0">Code lines (lines that can run)</td><td class="td-linebottomrt">217</td></tr><tr><td class="td-linebottomrt" bgcolor="#F0F0F0">Code lines that did run</td><td class="td-linebottomrt">197</td></tr><tr><td class="td-linebottomrt" bgcolor="#F0F0F0">Code lines that did not run</td><td class="td-linebottomrt">20</td></tr><tr><td class="td-linebottomrt" bgcolor="#F0F0F0">Coverage (did run/can run)</td><td class="td-linebottomrt">90.78 %</td></tr></table><div class="grayline"/><b>Function listing</b><br/><pre> <span style="color: #FF0000; font-weight: bold; text-decoration: none">  time</span> <span style="color: #0000FF; font-weight: bold; text-decoration: none">  calls</span>  <span style="font-weight: bold; text-decoration: none">line</span><br/>               <span style="color: #A0A0A0">   1</span> <span style="color: #A0A0A0; background: #FFFFFF;">function [DiagBlock, SampleList, RKTree, nDiagBlock] = ConstructHMatrix(N, nLevel)</span><br/>               <span style="color: #A0A0A0">   2</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/><a name="Line3"></a>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">   3</span> <span style="color: #000000; background: #FFFFFF;">solvetime = 0; </span><br/><a name="Line4"></a>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">   4</span> <span style="color: #000000; background: #FFFFFF;">RKmulttime = 0; </span><br/>               <span style="color: #A0A0A0">   5</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">   6</span> <span style="color: #000000; background: #FFFFFF;">DIRECT = 1; </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">   7</span> <span style="color: #000000; background: #FFFFFF;">INDIRECT = 0; </span><br/>               <span style="color: #A0A0A0">   8</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/><a name="Line9"></a>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">   9</span> <span style="color: #000000; background: #FFFFFF;">nWidthTop = N / 4; </span><br/>               <span style="color: #A0A0A0">  10</span> <span style="color: #228B22; background: #FFFFFF;">% nWidthBottom = 32;</span><br/>               <span style="color: #A0A0A0">  11</span> <span style="color: #228B22; background: #FFFFFF;">% nLevel = round( log2( nWidthTop / nWidthBottom ) + 1);</span><br/>               <span style="color: #A0A0A0">  12</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">  13</span> <span style="color: #000000; background: #FFFFFF;">maxRank = zeros(nLevel, 1); </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">  14</span> <span style="color: #000000; background: #FFFFFF;">maxRank(1) = 20; </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">  15</span> <span style="color: #000000; background: #FFFFFF;">maxRank(2:end) = 10; </span><br/>               <span style="color: #A0A0A0">  16</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">  17</span> <span style="color: #000000; background: #FFFFFF;">nSample = maxRank + 10; </span><br/>               <span style="color: #A0A0A0">  18</span> <span style="color: #228B22; background: #FFFFFF;">% SVDCut = 1d-6;</span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">  19</span> <span style="color: #000000; background: #FFFFFF;">SVDCut = zeros(nLevel, 1); </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">  20</span> <span style="color: #000000; background: #FFFFFF;">SVDCut(1) = 1e-6; </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">  21</span> <span style="color: #000000; background: #FFFFFF;">global svdcase; </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">  22</span> <span style="color: #000000; background: #FFFFFF;">switch svdcase </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">  23</span> <span style="color: #000000; background: #FFFFFF;">  case 1 </span><br/>               <span style="color: #A0A0A0">  24</span> <span style="color: #A0A0A0; background: #FFFFFF;">    for i = 2 : nLevel</span><br/>               <span style="color: #A0A0A0">  25</span> <span style="color: #A0A0A0; background: #FFFFFF;">      SVDCut(i) = SVDCut(i-1) / 2;</span><br/>               <span style="color: #A0A0A0">  26</span> <span style="color: #A0A0A0; background: #FFFFFF;">    end</span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">  27</span> <span style="color: #000000; background: #FFFFFF;">  case 2 </span><br/>               <span style="color: #A0A0A0">  28</span> <span style="color: #A0A0A0; background: #FFFFFF;">    for i = 2 : nLevel</span><br/>               <span style="color: #A0A0A0">  29</span> <span style="color: #A0A0A0; background: #FFFFFF;">      SVDCut(i) = SVDCut(i-1) / sqrt(2);</span><br/>               <span style="color: #A0A0A0">  30</span> <span style="color: #A0A0A0; background: #FFFFFF;">    end</span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">  31</span> <span style="color: #000000; background: #FFFFFF;">  case 3 </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">  32</span> <span style="color: #000000; background: #FFFFFF;">    for i = 2 : nLevel </span><br/>       <span style="color: #0000FF">      3 </span><span style="color: #000000; font-weight: bold">  33</span> <span style="color: #000000; background: #FFFFFF;">      SVDCut(i) = SVDCut(i-1); </span><br/>       <span style="color: #0000FF">      3 </span><span style="color: #000000; font-weight: bold">  34</span> <span style="color: #000000; background: #FFFFFF;">    end </span><br/>               <span style="color: #A0A0A0">  35</span> <span style="color: #A0A0A0; background: #FFFFFF;">  case 4</span><br/>               <span style="color: #A0A0A0">  36</span> <span style="color: #A0A0A0; background: #FFFFFF;">    for i = 2 : nLevel</span><br/>               <span style="color: #A0A0A0">  37</span> <span style="color: #A0A0A0; background: #FFFFFF;">      SVDCut(i) = SVDCut(i-1) * sqrt(2);</span><br/>               <span style="color: #A0A0A0">  38</span> <span style="color: #A0A0A0; background: #FFFFFF;">    end</span><br/>               <span style="color: #A0A0A0">  39</span> <span style="color: #A0A0A0; background: #FFFFFF;">  case 5</span><br/>               <span style="color: #A0A0A0">  40</span> <span style="color: #A0A0A0; background: #FFFFFF;">    for i = 2 : nLevel</span><br/>               <span style="color: #A0A0A0">  41</span> <span style="color: #A0A0A0; background: #FFFFFF;">      SVDCut(i) = SVDCut(i-1) * 2;</span><br/>               <span style="color: #A0A0A0">  42</span> <span style="color: #A0A0A0; background: #FFFFFF;">    end</span><br/>               <span style="color: #A0A0A0">  43</span> <span style="color: #A0A0A0; background: #FFFFFF;">end </span><br/>               <span style="color: #A0A0A0">  44</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/><span style="color: #FF0000">  2.77 </span><span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">  45</span> <span style="color: #000000; background: #FFFFFF;">SampleList = <a href="file4.html">ConstructSampleList</a>( N, nLevel ); </span><br/><span style="color: #FF0000">  1.83 </span><span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">  46</span> <span style="color: #000000; background: #FFFFFF;">RKTree = <a href="file5.html">ConstructRKTree</a>(N, nLevel, SampleList); </span><br/>               <span style="color: #A0A0A0">  47</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">  48</span> <span style="color: #000000; background: #FFFFFF;">display('Constructing RKTree...'); </span><br/>               <span style="color: #A0A0A0">  49</span> <span style="color: #A0A0A0; background: #FFFFFF;">if(1)</span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold">  50</span> <span style="color: #000000; background: #FFFFFF;">  for iLevel = 1 : nLevel </span><br/>       <span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold">  51</span> <span style="color: #000000; background: #FFFFFF;">    display( iLevel ) </span><br/>       <span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold">  52</span> <span style="color: #000000; background: #FFFFFF;">    tic </span><br/>               <span style="color: #A0A0A0">  53</span> <span style="color: #228B22; background: #FFFFFF;">    </span><br/>       <span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold">  54</span> <span style="color: #000000; background: #FFFFFF;">    nWidth = RKTree{iLevel}.nWidth; </span><br/>       <span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold">  55</span> <span style="color: #000000; background: #FFFFFF;">    nGroup = SampleList{iLevel}.nSource / ... </span><br/>               <span style="color: #A0A0A0">  56</span> <span style="color: #000000; background: #FFFFFF;">      SampleList{iLevel}.nParallel;</span><br/><span style="color: #FF0000">  0.06 </span><span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold">  57</span> <span style="color: #000000; background: #FFFFFF;">    TempR = randn( N, N, nSample(iLevel) ); </span><br/>       <span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold">  58</span> <span style="color: #000000; background: #FFFFFF;">    TempQ = cell(RKTree{iLevel}.nRKBlock, 1); </span><br/>               <span style="color: #A0A0A0">  59</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>               <span style="color: #A0A0A0">  60</span> <span style="color: #228B22; background: #FFFFFF;">    % Preparing random matrices</span><br/>       <span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold">  61</span> <span style="color: #000000; background: #FFFFFF;">    for i = 1 : RKTree{iLevel}.nRKBlock </span><br/><span style="color: #FF0000">  0.12 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold">  62</span> <span style="color: #000000; background: #FFFFFF;">      TempQ{i} = zeros( nWidth, nWidth, nSample(iLevel) ); </span><br/><span style="color: #FF0000">  0.02 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold">  63</span> <span style="color: #000000; background: #FFFFFF;">    end </span><br/>               <span style="color: #A0A0A0">  64</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>               <span style="color: #A0A0A0">  65</span> <span style="color: #228B22; background: #FFFFFF;">    % Applying the kernel to the random matrices</span><br/>       <span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold">  66</span> <span style="color: #000000; background: #FFFFFF;">    for iGroup = 1 : nGroup </span><br/>               <span style="color: #A0A0A0">  67</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/><span style="color: #FF0000">  0.11 </span><span style="color: #0000FF">    208 </span><span style="color: #000000; font-weight: bold">  68</span> <span style="color: #000000; background: #FFFFFF;">      TempMatApply = zeros( N, N, nSample(iLevel) ); </span><br/>       <span style="color: #0000FF">    208 </span><span style="color: #000000; font-weight: bold">  69</span> <span style="color: #000000; background: #FFFFFF;">      for iParallel = 1 : SampleList{iLevel}.nParallel </span><br/><span style="color: #FF0000">  0.02 </span><span style="color: #0000FF">   1360 </span><span style="color: #000000; font-weight: bold">  70</span> <span style="color: #000000; background: #FFFFFF;">	iSource = (iGroup-1) * SampleList{iLevel}.nParallel + ... </span><br/>               <span style="color: #A0A0A0">  71</span> <span style="color: #000000; background: #FFFFFF;">	  iParallel;</span><br/>       <span style="color: #0000FF">   1360 </span><span style="color: #000000; font-weight: bold">  72</span> <span style="color: #000000; background: #FFFFFF;">	Source = SampleList{iLevel}.Source( :, iSource ); </span><br/><span style="color: #FF0000">  0.07 </span><span style="color: #0000FF">   1360 </span><span style="color: #000000; font-weight: bold">  73</span> <span style="color: #000000; background: #FFFFFF;">	TempMatApply( 1+(Source(1)-1)*nWidth : ... </span><br/>               <span style="color: #A0A0A0">  74</span> <span style="color: #000000; background: #FFFFFF;">	    Source(1)*nWidth, ...</span><br/>               <span style="color: #A0A0A0">  75</span> <span style="color: #000000; background: #FFFFFF;">	    1+(Source(2)-1)*nWidth : ...</span><br/>               <span style="color: #A0A0A0">  76</span> <span style="color: #000000; background: #FFFFFF;">	    Source(2)*nWidth, : ) = ...</span><br/>               <span style="color: #A0A0A0">  77</span> <span style="color: #000000; background: #FFFFFF;">	    TempR( 1+(Source(1)-1)*nWidth : ...</span><br/>               <span style="color: #A0A0A0">  78</span> <span style="color: #000000; background: #FFFFFF;">	    Source(1)*nWidth, ...</span><br/>               <span style="color: #A0A0A0">  79</span> <span style="color: #000000; background: #FFFFFF;">	    1+(Source(2)-1)*nWidth : ...</span><br/>               <span style="color: #A0A0A0">  80</span> <span style="color: #000000; background: #FFFFFF;">	    Source(2)*nWidth, : );</span><br/>       <span style="color: #0000FF">   1360 </span><span style="color: #000000; font-weight: bold">  81</span> <span style="color: #000000; background: #FFFFFF;">      end </span><br/><span style="color: #FF0000"> 151.31 </span><span style="color: #0000FF">    208 </span><span style="color: #000000; font-weight: bold">  82</span> <a name="Line82"></a><span style="color: #000000; background: #FF8080;">      TempMatRes = <a href="file6.html">KernelApply</a>( N, reshape(... </span><br/>               <span style="color: #A0A0A0">  83</span> <span style="color: #000000; background: #FF8080;">	TempMatApply, N * N, nSample(iLevel) ) );</span><br/>       <span style="color: #0000FF">    208 </span><span style="color: #000000; font-weight: bold">  84</span> <span style="color: #000000; background: #FFFFFF;">      TempMatRes = reshape( TempMatRes, N, N, nSample(iLevel) );  </span><br/><span style="color: #FF0000"> 37.02 </span><span style="color: #0000FF">    208 </span><span style="color: #000000; font-weight: bold">  85</span> <a name="Line85"></a><span style="color: #000000; background: #FFE2E2;">      TempMatRKRes = <a href="file9.html">RKTreeApply</a>( SampleList, RKTree, TempMatApply, N, iLevel, nSample(iLevel) ); </span><br/><span style="color: #FF0000">  0.36 </span><span style="color: #0000FF">    208 </span><span style="color: #000000; font-weight: bold">  86</span> <span style="color: #000000; background: #FFFFFF;">      TempMatRes = TempMatRes - TempMatRKRes; </span><br/>               <span style="color: #A0A0A0">  87</span> <span style="color: #228B22; background: #FFFFFF;">        </span><br/>               <span style="color: #A0A0A0">  88</span> <span style="color: #228B22; background: #FFFFFF;">      % Extracting the blocks for each target and perform SVD</span><br/><span style="color: #FF0000">  0.02 </span><span style="color: #0000FF">    208 </span><span style="color: #000000; font-weight: bold">  89</span> <span style="color: #000000; background: #FFFFFF;">      for iParallel = 1 : SampleList{iLevel}.nParallel </span><br/><span style="color: #FF0000">  0.01 </span><span style="color: #0000FF">   1360 </span><span style="color: #000000; font-weight: bold">  90</span> <span style="color: #000000; background: #FFFFFF;">	iSource = (iGroup-1) * SampleList{iLevel}.nParallel + ... </span><br/>               <span style="color: #A0A0A0">  91</span> <span style="color: #000000; background: #FFFFFF;">	  iParallel;</span><br/><span style="color: #FF0000">  0.01 </span><span style="color: #0000FF">   1360 </span><span style="color: #000000; font-weight: bold">  92</span> <span style="color: #000000; background: #FFFFFF;">	for iTarget = 1 : SampleList{iLevel}.nTarget </span><br/><span style="color: #FF0000">  0.29 </span><span style="color: #0000FF">  36400 </span><span style="color: #000000; font-weight: bold">  93</span> <span style="color: #000000; background: #FFFFFF;">	  iRKBlock = SampleList{iLevel}.RKIndex(iTarget, iSource ); </span><br/><span style="color: #FF0000">  0.29 </span><span style="color: #0000FF">  36400 </span><span style="color: #000000; font-weight: bold">  94</span> <span style="color: #000000; background: #FFFFFF;">	  Target = SampleList{iLevel}.SourceTarget( :, ... </span><br/>               <span style="color: #A0A0A0">  95</span> <span style="color: #000000; background: #FFFFFF;">	    iTarget, iSource );</span><br/><span style="color: #FF0000">  0.48 </span><span style="color: #0000FF">  36400 </span><span style="color: #000000; font-weight: bold">  96</span> <span style="color: #000000; background: #FFFFFF;">	  TempT = TempMatRes(... </span><br/>               <span style="color: #A0A0A0">  97</span> <span style="color: #000000; background: #FFFFFF;">	    1+(Target(1)-1)*nWidth : ...</span><br/>               <span style="color: #A0A0A0">  98</span> <span style="color: #000000; background: #FFFFFF;">	    Target(1)*nWidth,  ...</span><br/>               <span style="color: #A0A0A0">  99</span> <span style="color: #000000; background: #FFFFFF;">	    1+(Target(2)-1)*nWidth : ...</span><br/>               <span style="color: #A0A0A0"> 100</span> <span style="color: #000000; background: #FFFFFF;">	    Target(2)*nWidth, : );</span><br/><a name="Line101"></a><span style="color: #FF0000">  7.06 </span><span style="color: #0000FF">  36400 </span><span style="color: #000000; font-weight: bold"> 101</span> <a name="Line101"></a><span style="color: #000000; background: #FFFFFF;">	  [TempU, TempS, TempW ] = svd( ... </span><br/>               <span style="color: #A0A0A0"> 102</span> <span style="color: #000000; background: #FFFFFF;">	    reshape( TempT, nWidth * nWidth, nSample(iLevel) ), 'econ' );</span><br/><a name="Line103"></a><span style="color: #FF0000">  0.73 </span><span style="color: #0000FF">  36400 </span><span style="color: #000000; font-weight: bold"> 103</span> <span style="color: #000000; background: #FFFFFF;">	  nRankU = min( max(find( abs(diag(TempS)) ./ max(abs(diag(TempS))) &gt; SVDCut(iLevel) )), ... </span><br/>               <span style="color: #A0A0A0"> 104</span> <span style="color: #000000; background: #FFFFFF;">	    maxRank(iLevel) );</span><br/><span style="color: #FF0000">  0.06 </span><span style="color: #0000FF">  36400 </span><span style="color: #000000; font-weight: bold"> 105</span> <span style="color: #000000; background: #FFFFFF;">	  if( nRankU == maxRank(iLevel)  ) </span><br/>               <span style="color: #A0A0A0"> 106</span> <span style="color: #A0A0A0; background: #FFFFFF;">	    disp('max rank reached')</span><br/>               <span style="color: #A0A0A0"> 107</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  end</span><br/><span style="color: #FF0000">  0.36 </span><span style="color: #0000FF">  36400 </span><span style="color: #000000; font-weight: bold"> 108</span> <span style="color: #000000; background: #FFFFFF;">	  if( SampleList{iLevel}.SymFlag(iTarget, iSource ) == DIRECT ) </span><br/><span style="color: #FF0000">  0.15 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 109</span> <span style="color: #000000; background: #FFFFFF;">	    RKTree{iLevel}.RKBlockU{ iRKBlock } = TempU(:, 1:nRankU ); </span><br/><span style="color: #FF0000">  0.18 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 110</span> <span style="color: #000000; background: #FFFFFF;">	    RKTree{iLevel}.RKBlockSDIRECT{ iRKBlock } = ... </span><br/>               <span style="color: #A0A0A0"> 111</span> <span style="color: #000000; background: #FFFFFF;">	      (TempS(1:nRankU,1:nRankU));</span><br/><span style="color: #FF0000">  0.06 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 112</span> <span style="color: #000000; background: #FFFFFF;">	    TempQ{iRKBlock} = TempT; </span><br/><span style="color: #FF0000">  0.01 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 113</span> <span style="color: #228B22; background: #FFFFFF;">	  else </span><br/><span style="color: #FF0000">  0.21 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 114</span> <span style="color: #000000; background: #FFFFFF;">	    RKTree{iLevel}.RKBlockV{ iRKBlock } = TempU(:, 1:nRankU ); </span><br/><span style="color: #FF0000">  0.15 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 115</span> <span style="color: #000000; background: #FFFFFF;">	    RKTree{iLevel}.RKBlockSINDIRECT{ iRKBlock } = ... </span><br/>               <span style="color: #A0A0A0"> 116</span> <span style="color: #000000; background: #FFFFFF;">	      (TempS(1:nRankU,1:nRankU));</span><br/><span style="color: #FF0000">  0.01 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 117</span> <span style="color: #000000; background: #FFFFFF;">	  end </span><br/><span style="color: #FF0000">  0.43 </span><span style="color: #0000FF">  36400 </span><span style="color: #000000; font-weight: bold"> 118</span> <span style="color: #000000; background: #FFFFFF;">	  clear TempT TempU TempS TempW; </span><br/>       <span style="color: #0000FF">  36400 </span><span style="color: #000000; font-weight: bold"> 119</span> <span style="color: #000000; background: #FFFFFF;">	end % iTarget </span><br/>       <span style="color: #0000FF">   1360 </span><span style="color: #000000; font-weight: bold"> 120</span> <span style="color: #000000; background: #FFFFFF;">      end % iParallel	 </span><br/>               <span style="color: #A0A0A0"> 121</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>       <span style="color: #0000FF">    208 </span><span style="color: #000000; font-weight: bold"> 122</span> <span style="color: #000000; background: #FFFFFF;">      clear TempMatApply TempMatRes TempMatRKRes; </span><br/>               <span style="color: #A0A0A0"> 123</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>       <span style="color: #0000FF">    208 </span><span style="color: #000000; font-weight: bold"> 124</span> <span style="color: #000000; background: #FFFFFF;">    end % iGroup </span><br/>               <span style="color: #A0A0A0"> 125</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>               <span style="color: #A0A0A0"> 126</span> <span style="color: #228B22; background: #FFFFFF;">    % Calculating Sigma and form low rank approximation</span><br/>       <span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold"> 127</span> <span style="color: #000000; background: #FFFFFF;">    for iRKBlock = 1 : RKTree{iLevel}.nRKBlock </span><br/><span style="color: #FF0000">  0.16 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 128</span> <span style="color: #000000; background: #FFFFFF;">      Source = RKTree{iLevel}.RKSource(:, :, iRKBlock); </span><br/><span style="color: #FF0000">  0.15 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 129</span> <span style="color: #000000; background: #FFFFFF;">      Target = RKTree{iLevel}.RKTarget(:, :, iRKBlock); </span><br/><span style="color: #FF0000">  0.29 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 130</span> <span style="color: #000000; background: #FFFFFF;">      TempR1 = reshape( ... </span><br/>               <span style="color: #A0A0A0"> 131</span> <span style="color: #000000; background: #FFFFFF;">	TempR( Source(1,1):Source(1,2), Source(2,1):Source(2,2), : ), ...</span><br/>               <span style="color: #A0A0A0"> 132</span> <span style="color: #000000; background: #FFFFFF;">	nWidth * nWidth, nSample(iLevel) );</span><br/><span style="color: #FF0000">  0.25 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 133</span> <span style="color: #000000; background: #FFFFFF;">      TempR2 = reshape( ... </span><br/>               <span style="color: #A0A0A0"> 134</span> <span style="color: #000000; background: #FFFFFF;">	TempR( Target(1,1):Target(1,2), Target(2,1):Target(2,2), : ), ...</span><br/>               <span style="color: #A0A0A0"> 135</span> <span style="color: #000000; background: #FFFFFF;">	nWidth * nWidth, nSample(iLevel) );</span><br/>               <span style="color: #A0A0A0"> 136</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/><span style="color: #FF0000">  6.29 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 137</span> <a name="Line137"></a><span style="color: #000000; background: #FFFFFF;">      RKTree{iLevel}.RKBlockM{iRKBlock} = <a href="file10.html">pinv</a>( transpose(TempR2) * ... </span><br/>               <span style="color: #A0A0A0"> 138</span> <span style="color: #000000; background: #FFFFFF;">	RKTree{iLevel}.RKBlockU{iRKBlock} ) * ...</span><br/>               <span style="color: #A0A0A0"> 139</span> <span style="color: #000000; background: #FFFFFF;">	transpose(TempR2) * reshape( ...</span><br/>               <span style="color: #A0A0A0"> 140</span> <span style="color: #000000; background: #FFFFFF;">	TempQ{iRKBlock}, nWidth * nWidth, nSample(iLevel) ) * ...</span><br/>               <span style="color: #A0A0A0"> 141</span> <span style="color: #000000; background: #FFFFFF;">	pinv( transpose(RKTree{iLevel}.RKBlockV{iRKBlock}) * ...</span><br/>               <span style="color: #A0A0A0"> 142</span> <span style="color: #000000; background: #FFFFFF;">	TempR1 );</span><br/>               <span style="color: #A0A0A0"> 143</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>               <span style="color: #A0A0A0"> 144</span> <span style="color: #228B22; background: #FFFFFF;">      % sizeSigma = size(TempSigma);</span><br/>               <span style="color: #A0A0A0"> 145</span> <span style="color: #228B22; background: #FFFFFF;">      % if( sizeSigma(1) &gt; sizeSigma(2) )</span><br/>               <span style="color: #A0A0A0"> 146</span> <span style="color: #228B22; background: #FFFFFF;">	% RKTree{iLevel}.RKBlockU{iRKBlock} = ...</span><br/>               <span style="color: #A0A0A0"> 147</span> <span style="color: #228B22; background: #FFFFFF;">	  % RKTree{iLevel}.RKBlockU{iRKBlock} * ...</span><br/>               <span style="color: #A0A0A0"> 148</span> <span style="color: #228B22; background: #FFFFFF;">	  % TempSigma;</span><br/>               <span style="color: #A0A0A0"> 149</span> <span style="color: #228B22; background: #FFFFFF;">	% RKTree{iLevel}.RKBlockV{iRKBlock} = ...</span><br/>               <span style="color: #A0A0A0"> 150</span> <span style="color: #228B22; background: #FFFFFF;">	  % RKTree{iLevel}.RKBlockV{iRKBlock};</span><br/>               <span style="color: #A0A0A0"> 151</span> <span style="color: #228B22; background: #FFFFFF;">      % else</span><br/>               <span style="color: #A0A0A0"> 152</span> <span style="color: #228B22; background: #FFFFFF;">	% RKTree{iLevel}.RKBlockU{iRKBlock} = ...</span><br/>               <span style="color: #A0A0A0"> 153</span> <span style="color: #228B22; background: #FFFFFF;">	  % RKTree{iLevel}.RKBlockU{iRKBlock};</span><br/>               <span style="color: #A0A0A0"> 154</span> <span style="color: #228B22; background: #FFFFFF;">	% RKTree{iLevel}.RKBlockV{iRKBlock} = ...</span><br/>               <span style="color: #A0A0A0"> 155</span> <span style="color: #228B22; background: #FFFFFF;">	  % RKTree{iLevel}.RKBlockV{iRKBlock} * ...</span><br/>               <span style="color: #A0A0A0"> 156</span> <span style="color: #228B22; background: #FFFFFF;">	  % transpose(TempSigma);</span><br/>               <span style="color: #A0A0A0"> 157</span> <span style="color: #228B22; background: #FFFFFF;">      % end</span><br/><span style="color: #FF0000">  0.17 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 158</span> <span style="color: #000000; background: #FFFFFF;">      clear TempR1 TempR2; </span><br/><span style="color: #FF0000">  0.03 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 159</span> <span style="color: #000000; background: #FFFFFF;">    end % iRKBlock </span><br/>               <span style="color: #A0A0A0"> 160</span> <span style="color: #228B22; background: #FFFFFF;">   </span><br/><span style="color: #FF0000">  0.01 </span><span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold"> 161</span> <span style="color: #000000; background: #FFFFFF;">    clear TempR TempQ; </span><br/>               <span style="color: #A0A0A0"> 162</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>               <span style="color: #A0A0A0"> 163</span> <span style="color: #228B22; background: #FFFFFF;">    % Uniformization</span><br/>       <span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold"> 164</span> <span style="color: #000000; background: #FFFFFF;">    for iSource = 1 : SampleList{iLevel}.nSource   </span><br/>       <span style="color: #0000FF">   1360 </span><span style="color: #000000; font-weight: bold"> 165</span> <span style="color: #000000; background: #FFFFFF;">      UAll = []; </span><br/>       <span style="color: #0000FF">   1360 </span><span style="color: #000000; font-weight: bold"> 166</span> <span style="color: #000000; background: #FFFFFF;">      for iTarget = 1 : SampleList{iLevel}.nTarget </span><br/><span style="color: #FF0000">  0.13 </span><span style="color: #0000FF">  36400 </span><span style="color: #000000; font-weight: bold"> 167</span> <span style="color: #000000; background: #FFFFFF;">	iRKBlock = SampleList{iLevel}.RKIndex(iTarget, iSource ); </span><br/>               <span style="color: #A0A0A0"> 168</span> <span style="color: #228B22; background: #FFFFFF;">	% Note that the following line is very strange. Source the</span><br/>               <span style="color: #A0A0A0"> 169</span> <span style="color: #228B22; background: #FFFFFF;">	% column direction and Target is the row direction for the</span><br/>               <span style="color: #A0A0A0"> 170</span> <span style="color: #228B22; background: #FFFFFF;">	% matrix. SymFlag is DIRECT if this is a lower diagonal block</span><br/>               <span style="color: #A0A0A0"> 171</span> <span style="color: #228B22; background: #FFFFFF;">	% matrix. However, G_{ij} need to be represented as</span><br/>               <span style="color: #A0A0A0"> 172</span> <span style="color: #228B22; background: #FFFFFF;">	%    G_{i,j} = U_{i} M_{ij} U_{j}^T </span><br/>               <span style="color: #A0A0A0"> 173</span> <span style="color: #228B22; background: #FFFFFF;">	%            = u_{ij} m_{ij} v_{ij}^T, </span><br/>               <span style="color: #A0A0A0"> 174</span> <span style="color: #228B22; background: #FFFFFF;">	% that is why we are compressing v direction instead of u</span><br/>               <span style="color: #A0A0A0"> 175</span> <span style="color: #228B22; background: #FFFFFF;">	% direction. We need a clear documentation about all these.</span><br/><span style="color: #FF0000">  0.24 </span><span style="color: #0000FF">  36400 </span><span style="color: #000000; font-weight: bold"> 176</span> <span style="color: #000000; background: #FFFFFF;">	if( SampleList{iLevel}.SymFlag(iTarget, iSource) == ... </span><br/>               <span style="color: #A0A0A0"> 177</span> <span style="color: #000000; background: #FFFFFF;">	    INDIRECT )</span><br/><a name="Line178"></a><span style="color: #FF0000">  0.48 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 178</span> <span style="color: #000000; background: #FFFFFF;">	  UAll = [UAll RKTree{iLevel}.RKBlockU{iRKBlock} * ... </span><br/>               <span style="color: #A0A0A0"> 179</span> <span style="color: #000000; background: #FFFFFF;">	    RKTree{iLevel}.RKBlockSDIRECT{iRKBlock}];</span><br/>       <span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 180</span> <span style="color: #228B22; background: #FFFFFF;">	else </span><br/><a name="Line181"></a><span style="color: #FF0000">  0.50 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 181</span> <span style="color: #000000; background: #FFFFFF;">	  UAll = [UAll RKTree{iLevel}.RKBlockV{iRKBlock} * ... </span><br/>               <span style="color: #A0A0A0"> 182</span> <span style="color: #000000; background: #FFFFFF;">	    RKTree{iLevel}.RKBlockSINDIRECT{iRKBlock}];</span><br/><span style="color: #FF0000">  0.01 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 183</span> <span style="color: #000000; background: #FFFFFF;">	end </span><br/><span style="color: #FF0000">  0.07 </span><span style="color: #0000FF">  36400 </span><span style="color: #000000; font-weight: bold"> 184</span> <span style="color: #000000; background: #FFFFFF;">      end %iTarget </span><br/>               <span style="color: #A0A0A0"> 185</span> <span style="color: #228B22; background: #FFFFFF;">      </span><br/>               <span style="color: #A0A0A0"> 186</span> <span style="color: #228B22; background: #FFFFFF;">      % SVD Version</span><br/><a name="Line187"></a><span style="color: #FF0000">  5.33 </span><span style="color: #0000FF">   1360 </span><span style="color: #000000; font-weight: bold"> 187</span> <span style="color: #000000; background: #FFFFFF;">      [TempU, TempS, TempV] = svd(UAll, 'econ'); </span><br/>               <span style="color: #A0A0A0"> 188</span> <span style="color: #228B22; background: #FFFFFF;">      % clf</span><br/>               <span style="color: #A0A0A0"> 189</span> <span style="color: #228B22; background: #FFFFFF;">      % semilogy(diag(TempS))</span><br/>               <span style="color: #A0A0A0"> 190</span> <span style="color: #228B22; background: #FFFFFF;">      % pause</span><br/><span style="color: #FF0000">  0.02 </span><span style="color: #0000FF">   1360 </span><span style="color: #000000; font-weight: bold"> 191</span> <span style="color: #000000; background: #FFFFFF;">      nRankU = ... </span><br/><a name="Line192"></a>               <span style="color: #A0A0A0"> 192</span> <span style="color: #000000; background: #FFFFFF;">	min( max(find( abs(diag(TempS)) ./ max(abs(diag(TempS))) &gt; SVDCut(iLevel) )), ...</span><br/>               <span style="color: #A0A0A0"> 193</span> <span style="color: #000000; background: #FFFFFF;">	4*maxRank(iLevel) );</span><br/>       <span style="color: #0000FF">   1360 </span><span style="color: #000000; font-weight: bold"> 194</span> <span style="color: #000000; background: #FFFFFF;">      if( nRankU == maxRank(iLevel) *4  ) </span><br/>               <span style="color: #A0A0A0"> 195</span> <span style="color: #A0A0A0; background: #FFFFFF;">	disp('max rank reached by uniformization')</span><br/>               <span style="color: #A0A0A0"> 196</span> <span style="color: #A0A0A0; background: #FFFFFF;">      end</span><br/><span style="color: #FF0000">  0.03 </span><span style="color: #0000FF">   1360 </span><span style="color: #000000; font-weight: bold"> 197</span> <span style="color: #000000; background: #FFFFFF;">      RKTree{iLevel}.RKBlockUniU{iSource} = TempU(:, 1:nRankU); </span><br/><span style="color: #FF0000">  0.01 </span><span style="color: #0000FF">   1360 </span><span style="color: #000000; font-weight: bold"> 198</span> <span style="color: #000000; background: #FFFFFF;">    end %iSource </span><br/>               <span style="color: #A0A0A0"> 199</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>       <span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold"> 200</span> <span style="color: #000000; background: #FFFFFF;">    nGroupWidth = round(sqrt(SampleList{iLevel}.nSource / ... </span><br/>               <span style="color: #A0A0A0"> 201</span> <span style="color: #000000; background: #FFFFFF;">      SampleList{iLevel}.nParallel));</span><br/>       <span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold"> 202</span> <span style="color: #000000; background: #FFFFFF;">    nParallelWidth = round(sqrt(SampleList{iLevel}.nParallel)); </span><br/>       <span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold"> 203</span> <span style="color: #000000; background: #FFFFFF;">    nParallel = SampleList{iLevel}.nParallel; </span><br/>               <span style="color: #A0A0A0"> 204</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>               <span style="color: #A0A0A0"> 205</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>       <span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold"> 206</span> <span style="color: #000000; background: #FFFFFF;">    for iSource = 1 : SampleList{iLevel}.nSource </span><br/>       <span style="color: #0000FF">   1360 </span><span style="color: #000000; font-weight: bold"> 207</span> <span style="color: #000000; background: #FFFFFF;">      for iTarget = 1 : SampleList{iLevel}.nTarget </span><br/><span style="color: #FF0000">  0.17 </span><span style="color: #0000FF">  36400 </span><span style="color: #000000; font-weight: bold"> 208</span> <span style="color: #000000; background: #FFFFFF;">	iRKBlock = SampleList{iLevel}.RKIndex(iTarget, iSource ); </span><br/><span style="color: #FF0000">  0.20 </span><span style="color: #0000FF">  36400 </span><span style="color: #000000; font-weight: bold"> 209</span> <span style="color: #000000; background: #FFFFFF;">	if( SampleList{iLevel}.SymFlag(iTarget, iSource) == ... </span><br/>               <span style="color: #A0A0A0"> 210</span> <span style="color: #000000; background: #FFFFFF;">	    DIRECT )</span><br/><span style="color: #FF0000">  0.20 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 211</span> <span style="color: #000000; background: #FFFFFF;">	  TargetPos = ... </span><br/>               <span style="color: #A0A0A0"> 212</span> <span style="color: #000000; background: #FFFFFF;">	    SampleList{iLevel}.SourceTarget(:, iTarget, iSource);</span><br/>               <span style="color: #A0A0A0"> 213</span> <span style="color: #228B22; background: #FFFFFF;">	  </span><br/>       <span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 214</span> <span style="color: #000000; background: #FFFFFF;">	  nGroupRow = floor( (TargetPos(1)-1)/nGroupWidth ) + 1; </span><br/><span style="color: #FF0000">  0.02 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 215</span> <span style="color: #000000; background: #FFFFFF;">	  nGroupCol = floor( (TargetPos(2)-1)/nGroupWidth ) + 1; </span><br/>       <span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 216</span> <span style="color: #000000; background: #FFFFFF;">	  nBlockRow = mod( (TargetPos(1)-1), nGroupWidth ) + 1; </span><br/>       <span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 217</span> <span style="color: #000000; background: #FFFFFF;">	  nBlockCol = mod( (TargetPos(2)-1), nGroupWidth ) + 1; </span><br/><span style="color: #FF0000">  0.04 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 218</span> <span style="color: #000000; background: #FFFFFF;">	  TargetInd = nParallel * ( nBlockRow-1 + (nBlockCol-1) * ... </span><br/>               <span style="color: #A0A0A0"> 219</span> <span style="color: #000000; background: #FFFFFF;">	    nGroupWidth ) + (nGroupCol-1) * nParallelWidth + ...</span><br/>               <span style="color: #A0A0A0"> 220</span> <span style="color: #000000; background: #FFFFFF;">	    nGroupRow;</span><br/>               <span style="color: #A0A0A0"> 221</span> <span style="color: #228B22; background: #FFFFFF;">	 </span><br/>               <span style="color: #A0A0A0"> 222</span> <span style="color: #228B22; background: #FFFFFF;">	  % Note the order of RKBlockUniU here, we need a clear</span><br/>               <span style="color: #A0A0A0"> 223</span> <span style="color: #228B22; background: #FFFFFF;">	  % documentation.</span><br/><span style="color: #FF0000">  0.86 </span><span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 224</span> <span style="color: #000000; background: #FFFFFF;">	  RKTree{iLevel}.RKBlockUniM{iRKBlock} = ... </span><br/>               <span style="color: #A0A0A0"> 225</span> <span style="color: #000000; background: #FFFFFF;">	    transpose(RKTree{iLevel}.RKBlockUniU{TargetInd}) * ...</span><br/>               <span style="color: #A0A0A0"> 226</span> <span style="color: #000000; background: #FFFFFF;">	    RKTree{iLevel}.RKBlockU{iRKBlock} * ...</span><br/>               <span style="color: #A0A0A0"> 227</span> <span style="color: #000000; background: #FFFFFF;">	    RKTree{iLevel}.RKBlockM{iRKBlock} * ...</span><br/>               <span style="color: #A0A0A0"> 228</span> <span style="color: #000000; background: #FFFFFF;">	    transpose(RKTree{iLevel}.RKBlockV{iRKBlock}) * ...;</span><br/>               <span style="color: #A0A0A0"> 229</span> <span style="color: #000000; background: #FFFFFF;">	    RKTree{iLevel}.RKBlockUniU{iSource};</span><br/>       <span style="color: #0000FF">  18200 </span><span style="color: #000000; font-weight: bold"> 230</span> <span style="color: #000000; background: #FFFFFF;">	end </span><br/><span style="color: #FF0000">  0.03 </span><span style="color: #0000FF">  36400 </span><span style="color: #000000; font-weight: bold"> 231</span> <span style="color: #000000; background: #FFFFFF;">      end  % iTarget </span><br/>       <span style="color: #0000FF">   1360 </span><span style="color: #000000; font-weight: bold"> 232</span> <span style="color: #000000; background: #FFFFFF;">    end % iSource </span><br/>               <span style="color: #A0A0A0"> 233</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>               <span style="color: #A0A0A0"> 234</span> <span style="color: #228B22; background: #FFFFFF;">    % Clear</span><br/>               <span style="color: #A0A0A0"> 235</span> <span style="color: #228B22; background: #FFFFFF;">    % for iRKBlock = 1 : RKTree{iLevel}.nRKBlock</span><br/>               <span style="color: #A0A0A0"> 236</span> <span style="color: #228B22; background: #FFFFFF;">      % sqrt(sum(RKTree{iLevel}.RKBlockV{iRKBlock}.^2,1))</span><br/>               <span style="color: #A0A0A0"> 237</span> <span style="color: #228B22; background: #FFFFFF;">    % end</span><br/><span style="color: #FF0000">  0.01 </span><span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold"> 238</span> <span style="color: #000000; background: #FFFFFF;">    RKTree{iLevel}.RKBlockU = []; </span><br/><span style="color: #FF0000">  0.01 </span><span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold"> 239</span> <span style="color: #000000; background: #FFFFFF;">    RKTree{iLevel}.RKBlockV = []; </span><br/>       <span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold"> 240</span> <span style="color: #000000; background: #FFFFFF;">    RKTree{iLevel}.RKBlockM = []; </span><br/><span style="color: #FF0000">  0.01 </span><span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold"> 241</span> <span style="color: #000000; background: #FFFFFF;">    RKTree{iLevel}.RKBlockSDIRECT = []; </span><br/><span style="color: #FF0000">  0.01 </span><span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold"> 242</span> <span style="color: #000000; background: #FFFFFF;">    RKTree{iLevel}.RKBlockSINDIRECT = []; </span><br/>               <span style="color: #A0A0A0"> 243</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>       <span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold"> 244</span> <span style="color: #000000; background: #FFFFFF;">    toc </span><br/>       <span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold"> 245</span> <span style="color: #000000; background: #FFFFFF;">  end % iLevel </span><br/>               <span style="color: #A0A0A0"> 246</span> <span style="color: #A0A0A0; background: #FFFFFF;">end</span><br/>               <span style="color: #A0A0A0"> 247</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>               <span style="color: #A0A0A0"> 248</span> <span style="color: #228B22; background: #FFFFFF;">% Extract diag part</span><br/>               <span style="color: #A0A0A0"> 249</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 250</span> <span style="color: #000000; background: #FFFFFF;">display('Extracting diagonal...'); </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 251</span> <span style="color: #000000; background: #FFFFFF;">tic </span><br/>               <span style="color: #A0A0A0"> 252</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>               <span style="color: #A0A0A0"> 253</span> <span style="color: #228B22; background: #FFFFFF;">% nWidth is doubled because we cannot sample two adjacent blocks.</span><br/>               <span style="color: #A0A0A0"> 254</span> <span style="color: #228B22; background: #FFFFFF;">% nBlockPre = round( N / nWidth );</span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 255</span> <span style="color: #000000; background: #FFFFFF;">nWidthPre = nWidth; </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 256</span> <span style="color: #000000; background: #FFFFFF;">nWidth = nWidth * 4; </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 257</span> <span style="color: #000000; background: #FFFFFF;">nBlockCur = round( N / nWidth ); </span><br/>               <span style="color: #A0A0A0"> 258</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>               <span style="color: #A0A0A0"> 259</span> <span style="color: #A0A0A0; background: #FFFFFF;">if( 0 ) % when there is access to large memory</span><br/>               <span style="color: #A0A0A0"> 260</span> <span style="color: #A0A0A0; background: #FFFFFF;">  nDiagBlock = 4*4*nBlockCur*nBlockCur;</span><br/>               <span style="color: #A0A0A0"> 261</span> <span style="color: #A0A0A0; background: #FFFFFF;">  DiagBlock = cell(nDiagBlock, 1);</span><br/>               <span style="color: #A0A0A0"> 262</span> <span style="color: #A0A0A0; background: #FFFFFF;">  for i = 1 : nDiagBlock</span><br/>               <span style="color: #A0A0A0"> 263</span> <span style="color: #A0A0A0; background: #FFFFFF;">    DiagBlock{i} = struct('indSource', [], ...</span><br/>               <span style="color: #A0A0A0"> 264</span> <span style="color: #A0A0A0; background: #FFFFFF;">      'indTarget', [], ...</span><br/>               <span style="color: #A0A0A0"> 265</span> <span style="color: #A0A0A0; background: #FFFFFF;">      'Mat', [] );</span><br/>               <span style="color: #A0A0A0"> 266</span> <span style="color: #A0A0A0; background: #FFFFFF;">  end</span><br/>               <span style="color: #A0A0A0"> 267</span> <span style="color: #A0A0A0; background: #FFFFFF;">  nSampleDiag = nWidth * nWidth;</span><br/>               <span style="color: #A0A0A0"> 268</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>               <span style="color: #A0A0A0"> 269</span> <span style="color: #A0A0A0; background: #FFFFFF;">  disp('Generating pattern');</span><br/>               <span style="color: #A0A0A0"> 270</span> <span style="color: #A0A0A0; background: #FFFFFF;">  TempMatApply = zeros( N, N, nSampleDiag );</span><br/>               <span style="color: #A0A0A0"> 271</span> <span style="color: #A0A0A0; background: #FFFFFF;">  for iSourceX = 1 : nWidth</span><br/><a name="Line272"></a>               <span style="color: #A0A0A0"> 272</span> <span style="color: #A0A0A0; background: #FFFFFF;">  for iSourceY = 1 : nWidth</span><br/>               <span style="color: #A0A0A0"> 273</span> <span style="color: #A0A0A0; background: #FFFFFF;">      SourceYInd = iSourceY : nWidth : N;</span><br/>               <span style="color: #A0A0A0"> 274</span> <span style="color: #A0A0A0; background: #FFFFFF;">      SourceXInd = iSourceX : nWidth : N;</span><br/>               <span style="color: #A0A0A0"> 275</span> <span style="color: #A0A0A0; background: #FFFFFF;">      ind = iSourceY + (iSourceX-1) * nWidth;</span><br/>               <span style="color: #A0A0A0"> 276</span> <span style="color: #A0A0A0; background: #FFFFFF;">      TempMatApply(SourceYInd, SourceXInd, ind) = 1;</span><br/>               <span style="color: #A0A0A0"> 277</span> <span style="color: #A0A0A0; background: #FFFFFF;">    end</span><br/>               <span style="color: #A0A0A0"> 278</span> <span style="color: #A0A0A0; background: #FFFFFF;">  end</span><br/>               <span style="color: #A0A0A0"> 279</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>               <span style="color: #A0A0A0"> 280</span> <span style="color: #A0A0A0; background: #FFFFFF;">  disp('Calculating');</span><br/>               <span style="color: #A0A0A0"> 281</span> <span style="color: #A0A0A0; background: #FFFFFF;">  TempMatRes = KernelApply( N, reshape(...</span><br/>               <span style="color: #A0A0A0"> 282</span> <span style="color: #A0A0A0; background: #FFFFFF;">    TempMatApply, N * N, nSampleDiag) );</span><br/>               <span style="color: #A0A0A0"> 283</span> <span style="color: #A0A0A0; background: #FFFFFF;">  TempMatRes = reshape( TempMatRes, N, N, nSampleDiag ); </span><br/>               <span style="color: #A0A0A0"> 284</span> <span style="color: #A0A0A0; background: #FFFFFF;">  TempMatRKRes = RKTreeApply( SampleList, RKTree, TempMatApply, N, nLevel+1, nSampleDiag );</span><br/>               <span style="color: #A0A0A0"> 285</span> <span style="color: #A0A0A0; background: #FFFFFF;">  TempMatRes = TempMatRes - TempMatRKRes;</span><br/>               <span style="color: #A0A0A0"> 286</span> <span style="color: #A0A0A0; background: #FFFFFF;">  TempMatRes = reshape( TempMatRes, N*N, nSampleDiag );</span><br/>               <span style="color: #A0A0A0"> 287</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>               <span style="color: #A0A0A0"> 288</span> <span style="color: #A0A0A0; background: #FFFFFF;">  disp('Redistributing');</span><br/>               <span style="color: #A0A0A0"> 289</span> <span style="color: #A0A0A0; background: #FFFFFF;">  cDiagBlock = 0;</span><br/>               <span style="color: #A0A0A0"> 290</span> <span style="color: #A0A0A0; background: #FFFFFF;">  for j = 1 : 4</span><br/>               <span style="color: #A0A0A0"> 291</span> <span style="color: #A0A0A0; background: #FFFFFF;">    for i = 1 : 4</span><br/>               <span style="color: #A0A0A0"> 292</span> <span style="color: #A0A0A0; background: #FFFFFF;">      iTempSourceArr = ( ((i-1)*nWidthPre + 1) : i*nWidthPre )';</span><br/>               <span style="color: #A0A0A0"> 293</span> <span style="color: #A0A0A0; background: #FFFFFF;">      jTempSourceArr = ( ((j-1)*nWidthPre + 1) : j*nWidthPre );</span><br/>               <span style="color: #A0A0A0"> 294</span> <span style="color: #A0A0A0; background: #FFFFFF;">      indTempSource = repmat( (jTempSourceArr-1)*nWidth, length(iTempSourceArr), 1 ) + ...</span><br/>               <span style="color: #A0A0A0"> 295</span> <span style="color: #A0A0A0; background: #FFFFFF;">	repmat( iTempSourceArr, 1, length(jTempSourceArr) );</span><br/>               <span style="color: #A0A0A0"> 296</span> <span style="color: #A0A0A0; background: #FFFFFF;">      indTempSource = reshape(indTempSource, [], 1);</span><br/>               <span style="color: #A0A0A0"> 297</span> <span style="color: #A0A0A0; background: #FFFFFF;">      for k = 1 : nBlockCur</span><br/>               <span style="color: #A0A0A0"> 298</span> <span style="color: #A0A0A0; background: #FFFFFF;">	for l = 1 : nBlockCur</span><br/>               <span style="color: #A0A0A0"> 299</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  iSource = (k-1)*nWidth + (i-1)*nWidthPre + 1;</span><br/>               <span style="color: #A0A0A0"> 300</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  jSource = (l-1)*nWidth + (j-1)*nWidthPre + 1;</span><br/>               <span style="color: #A0A0A0"> 301</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  iSourceArr = (iSource:iSource+nWidthPre-1)';</span><br/>               <span style="color: #A0A0A0"> 302</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  jSourceArr = (jSource:jSource+nWidthPre-1);</span><br/>               <span style="color: #A0A0A0"> 303</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  indSource = repmat( (jSourceArr-1)*N, length(iSourceArr), 1 ) + ...</span><br/>               <span style="color: #A0A0A0"> 304</span> <span style="color: #A0A0A0; background: #FFFFFF;">	    repmat( iSourceArr, 1, length(jSourceArr) );</span><br/>               <span style="color: #A0A0A0"> 305</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  indSource = reshape(indSource, [], 1);</span><br/>               <span style="color: #A0A0A0"> 306</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  iSourceBlk = (k-1)*4 + i;</span><br/>               <span style="color: #A0A0A0"> 307</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  jSourceBlk = (l-1)*4 + j;</span><br/>               <span style="color: #A0A0A0"> 308</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  iTarget1 = (iSourceBlk-2) * nWidthPre + 1;</span><br/>               <span style="color: #A0A0A0"> 309</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  iTarget2 = (iSourceBlk+1) * nWidthPre;</span><br/>               <span style="color: #A0A0A0"> 310</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  jTarget1 = (jSourceBlk-2) * nWidthPre + 1;</span><br/>               <span style="color: #A0A0A0"> 311</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  jTarget2 = (jSourceBlk+1) * nWidthPre;</span><br/>               <span style="color: #A0A0A0"> 312</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  iTargetArr = (iTarget1:iTarget2)';</span><br/>               <span style="color: #A0A0A0"> 313</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  jTargetArr = jTarget1:jTarget2;</span><br/>               <span style="color: #A0A0A0"> 314</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  iTargetArr = mod( iTargetArr - 1, N ) + 1;</span><br/>               <span style="color: #A0A0A0"> 315</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  jTargetArr = mod( jTargetArr - 1, N ) + 1;</span><br/>               <span style="color: #A0A0A0"> 316</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  indTarget = repmat( (jTargetArr-1)*N, length(iTargetArr), 1 ) + ...</span><br/>               <span style="color: #A0A0A0"> 317</span> <span style="color: #A0A0A0; background: #FFFFFF;">	    repmat( iTargetArr, 1, length(jTargetArr) );</span><br/>               <span style="color: #A0A0A0"> 318</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  indTarget = reshape(indTarget, [], 1);</span><br/>               <span style="color: #A0A0A0"> 319</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  cDiagBlock = cDiagBlock + 1;</span><br/>               <span style="color: #A0A0A0"> 320</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  DiagBlock{cDiagBlock}.indSource = indSource;</span><br/>               <span style="color: #A0A0A0"> 321</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  DiagBlock{cDiagBlock}.indTarget = indTarget;</span><br/>               <span style="color: #A0A0A0"> 322</span> <span style="color: #A0A0A0; background: #FFFFFF;">	  DiagBlock{cDiagBlock}.Mat = ...</span><br/>               <span style="color: #A0A0A0"> 323</span> <span style="color: #A0A0A0; background: #FFFFFF;">	    (TempMatRes(indTarget, indTempSource)).';</span><br/>               <span style="color: #A0A0A0"> 324</span> <span style="color: #A0A0A0; background: #FFFFFF;">	end</span><br/>               <span style="color: #A0A0A0"> 325</span> <span style="color: #A0A0A0; background: #FFFFFF;">      end</span><br/>               <span style="color: #A0A0A0"> 326</span> <span style="color: #A0A0A0; background: #FFFFFF;">    end</span><br/>               <span style="color: #A0A0A0"> 327</span> <span style="color: #A0A0A0; background: #FFFFFF;">  end</span><br/>               <span style="color: #A0A0A0"> 328</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>               <span style="color: #A0A0A0"> 329</span> <span style="color: #A0A0A0; background: #FFFFFF;">end</span><br/>               <span style="color: #A0A0A0"> 330</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>               <span style="color: #A0A0A0"> 331</span> <span style="color: #A0A0A0; background: #FFFFFF;">if( 1 ) % when memory is not enough</span><br/>               <span style="color: #A0A0A0"> 332</span> <span style="color: #228B22; background: #FFFFFF;">  % The first dimension: i, k, or Y</span><br/>               <span style="color: #A0A0A0"> 333</span> <span style="color: #228B22; background: #FFFFFF;">  % The second dimension: j, l, or X</span><br/>               <span style="color: #A0A0A0"> 334</span> <span style="color: #228B22; background: #FFFFFF;">  %</span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 335</span> <span style="color: #000000; background: #FFFFFF;">  nDiagBlock = 4*4*nBlockCur*nBlockCur; </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 336</span> <span style="color: #000000; background: #FFFFFF;">  DiagBlock = cell(nDiagBlock, 1); </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 337</span> <span style="color: #000000; background: #FFFFFF;">  for i = 1 : nDiagBlock </span><br/><span style="color: #FF0000">  0.01 </span><span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 338</span> <span style="color: #000000; background: #FFFFFF;">    DiagBlock{i} = struct('indSource', [], ... </span><br/>               <span style="color: #A0A0A0"> 339</span> <span style="color: #000000; background: #FFFFFF;">      'indTarget', [], ...</span><br/>               <span style="color: #A0A0A0"> 340</span> <span style="color: #000000; background: #FFFFFF;">      'Mat', [] );</span><br/>       <span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 341</span> <span style="color: #000000; background: #FFFFFF;">  end </span><br/><a name="Line342"></a>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 342</span> <span style="color: #000000; background: #FFFFFF;">  nSampleDiag = nWidth * nWidth; </span><br/>               <span style="color: #A0A0A0"> 343</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 344</span> <span style="color: #000000; background: #FFFFFF;">  cDiagBlock = 0; </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 345</span> <span style="color: #000000; background: #FFFFFF;">  for j = 1 : 4 </span><br/>       <span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold"> 346</span> <span style="color: #000000; background: #FFFFFF;">    for i = 1 : 4 </span><br/>       <span style="color: #0000FF">     16 </span><span style="color: #000000; font-weight: bold"> 347</span> <span style="color: #000000; background: #FFFFFF;">      for k = 1 : nBlockCur </span><br/>       <span style="color: #0000FF">    128 </span><span style="color: #000000; font-weight: bold"> 348</span> <span style="color: #000000; background: #FFFFFF;">	for l = 1 : nBlockCur </span><br/>       <span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 349</span> <span style="color: #000000; background: #FFFFFF;">	  iSource = (k-1)*nWidth + (i-1)*nWidthPre + 1; </span><br/>       <span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 350</span> <span style="color: #000000; background: #FFFFFF;">	  jSource = (l-1)*nWidth + (j-1)*nWidthPre + 1; </span><br/>       <span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 351</span> <span style="color: #000000; background: #FFFFFF;">	  iSourceArr = (iSource:iSource+nWidthPre-1)'; </span><br/>       <span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 352</span> <span style="color: #000000; background: #FFFFFF;">	  jSourceArr = (jSource:jSource+nWidthPre-1); </span><br/><span style="color: #FF0000">  0.08 </span><span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 353</span> <span style="color: #000000; background: #FFFFFF;">	  indSource = <a href="file11.html">repmat</a>( (jSourceArr-1)*N, length(iSourceArr), 1 ) + ... </span><br/>               <span style="color: #A0A0A0"> 354</span> <span style="color: #000000; background: #FFFFFF;">	    repmat( iSourceArr, 1, length(jSourceArr) );</span><br/><span style="color: #FF0000">  0.02 </span><span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 355</span> <span style="color: #000000; background: #FFFFFF;">	  indSource = reshape(indSource, [], 1); </span><br/>       <span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 356</span> <span style="color: #000000; background: #FFFFFF;">	  iSourceBlk = (k-1)*4 + i; </span><br/>       <span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 357</span> <span style="color: #000000; background: #FFFFFF;">	  jSourceBlk = (l-1)*4 + j; </span><br/>       <span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 358</span> <span style="color: #000000; background: #FFFFFF;">	  iTarget1 = (iSourceBlk-2) * nWidthPre + 1; </span><br/>       <span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 359</span> <span style="color: #000000; background: #FFFFFF;">	  iTarget2 = (iSourceBlk+1) * nWidthPre; </span><br/>       <span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 360</span> <span style="color: #000000; background: #FFFFFF;">	  jTarget1 = (jSourceBlk-2) * nWidthPre + 1; </span><br/>       <span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 361</span> <span style="color: #000000; background: #FFFFFF;">	  jTarget2 = (jSourceBlk+1) * nWidthPre; </span><br/><span style="color: #FF0000">  0.01 </span><span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 362</span> <span style="color: #000000; background: #FFFFFF;">	  iTargetArr = (iTarget1:iTarget2)'; </span><br/>       <span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 363</span> <span style="color: #000000; background: #FFFFFF;">	  jTargetArr = jTarget1:jTarget2; </span><br/>       <span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 364</span> <span style="color: #000000; background: #FFFFFF;">	  iTargetArr = mod( iTargetArr - 1, N ) + 1; </span><br/>       <span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 365</span> <span style="color: #000000; background: #FFFFFF;">	  jTargetArr = mod( jTargetArr - 1, N ) + 1; </span><br/><span style="color: #FF0000">  0.08 </span><span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 366</span> <span style="color: #000000; background: #FFFFFF;">	  indTarget = <a href="file11.html">repmat</a>( (jTargetArr-1)*N, length(iTargetArr), 1 ) + ... </span><br/>               <span style="color: #A0A0A0"> 367</span> <span style="color: #000000; background: #FFFFFF;">	    repmat( iTargetArr, 1, length(jTargetArr) );</span><br/><span style="color: #FF0000">  0.02 </span><span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 368</span> <span style="color: #000000; background: #FFFFFF;">	  indTarget = reshape(indTarget, [], 1); </span><br/>       <span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 369</span> <span style="color: #000000; background: #FFFFFF;">	  cDiagBlock = cDiagBlock + 1; </span><br/>       <span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 370</span> <span style="color: #000000; background: #FFFFFF;">	  DiagBlock{cDiagBlock}.indSource = indSource; </span><br/>       <span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 371</span> <span style="color: #000000; background: #FFFFFF;">	  DiagBlock{cDiagBlock}.indTarget = indTarget; </span><br/>       <span style="color: #0000FF">   1024 </span><span style="color: #000000; font-weight: bold"> 372</span> <span style="color: #000000; background: #FFFFFF;">	end </span><br/>       <span style="color: #0000FF">    128 </span><span style="color: #000000; font-weight: bold"> 373</span> <span style="color: #000000; background: #FFFFFF;">      end </span><br/>       <span style="color: #0000FF">     16 </span><span style="color: #000000; font-weight: bold"> 374</span> <span style="color: #000000; background: #FFFFFF;">    end </span><br/>       <span style="color: #0000FF">      4 </span><span style="color: #000000; font-weight: bold"> 375</span> <span style="color: #000000; background: #FFFFFF;">  end </span><br/>               <span style="color: #A0A0A0"> 376</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 377</span> <span style="color: #000000; background: #FFFFFF;">  nVecMax = 400; </span><br/>               <span style="color: #A0A0A0"> 378</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/><span style="color: #FF0000">  0.04 </span><span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 379</span> <span style="color: #000000; background: #FFFFFF;">  TempMatApply = zeros( N, N, nVecMax ); </span><br/><a name="Line380"></a><span style="color: #FF0000">  0.05 </span><span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 380</span> <span style="color: #000000; background: #FFFFFF;">  TempMatRes = zeros(N, N, nVecMax); </span><br/><a name="Line381"></a><span style="color: #FF0000">  0.04 </span><span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 381</span> <span style="color: #000000; background: #FFFFFF;">  TempMatRKRes = zeros(N, N, nVecMax); </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 382</span> <span style="color: #000000; background: #FFFFFF;">  cVec = 0; </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 383</span> <span style="color: #000000; background: #FFFFFF;">  arrSourceY = zeros(nVecMax); </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 384</span> <span style="color: #000000; background: #FFFFFF;">  arrSourceX = zeros(nVecMax); </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 385</span> <span style="color: #000000; background: #FFFFFF;">  for iSourceX = 1 : nWidth </span><br/>       <span style="color: #0000FF">     16 </span><span style="color: #000000; font-weight: bold"> 386</span> <span style="color: #000000; background: #FFFFFF;">    for iSourceY = 1 : nWidth </span><br/>               <span style="color: #A0A0A0"> 387</span> <span style="color: #228B22; background: #FFFFFF;">     </span><br/>       <span style="color: #0000FF">    256 </span><span style="color: #000000; font-weight: bold"> 388</span> <span style="color: #000000; background: #FFFFFF;">      cVec = cVec + 1; </span><br/>       <span style="color: #0000FF">    256 </span><span style="color: #000000; font-weight: bold"> 389</span> <span style="color: #000000; background: #FFFFFF;">      arrSourceY(cVec) = iSourceY; </span><br/>       <span style="color: #0000FF">    256 </span><span style="color: #000000; font-weight: bold"> 390</span> <span style="color: #000000; background: #FFFFFF;">      arrSourceX(cVec) = iSourceX; </span><br/>       <span style="color: #0000FF">    256 </span><span style="color: #000000; font-weight: bold"> 391</span> <span style="color: #000000; background: #FFFFFF;">      SourceYInd = iSourceY : nWidth : N; </span><br/>       <span style="color: #0000FF">    256 </span><span style="color: #000000; font-weight: bold"> 392</span> <span style="color: #000000; background: #FFFFFF;">      SourceXInd = iSourceX : nWidth : N; </span><br/>       <span style="color: #0000FF">    256 </span><span style="color: #000000; font-weight: bold"> 393</span> <span style="color: #000000; background: #FFFFFF;">      TempMatApply(SourceYInd, SourceXInd, cVec) = 1; </span><br/>       <span style="color: #0000FF">    256 </span><span style="color: #000000; font-weight: bold"> 394</span> <span style="color: #000000; background: #FFFFFF;">      if( (cVec &lt; nVecMax) &amp;&amp; ((iSourceX&lt;nWidth) || (iSourceY&lt;nWidth)) ) </span><br/><span style="color: #FF0000">  0.01 </span><span style="color: #0000FF">    255 </span><span style="color: #000000; font-weight: bold"> 395</span> <span style="color: #000000; background: #FFFFFF;">	continue; </span><br/>               <span style="color: #A0A0A0"> 396</span> <span style="color: #A0A0A0; background: #FFFFFF;">      end</span><br/>               <span style="color: #A0A0A0"> 397</span> <span style="color: #228B22; background: #FFFFFF;">     </span><br/><span style="color: #FF0000"> 14.55 </span><span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 398</span> <a name="Line398"></a><span style="color: #000000; background: #FFFFFF;">      TempMatRes = <a href="file6.html">KernelApply</a>( N, reshape(... </span><br/>               <span style="color: #A0A0A0"> 399</span> <span style="color: #000000; background: #FFFFFF;">	TempMatApply, N * N, nVecMax) );</span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 400</span> <span style="color: #000000; background: #FFFFFF;">      TempMatRes = reshape( TempMatRes, N, N, nVecMax );  </span><br/><span style="color: #FF0000">  5.55 </span><span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 401</span> <span style="color: #000000; background: #FFFFFF;">      TempMatRKRes = <a href="file9.html">RKTreeApply</a>( SampleList, RKTree, TempMatApply, N, nLevel+1, nVecMax); </span><br/><span style="color: #FF0000">  0.05 </span><span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 402</span> <span style="color: #000000; background: #FFFFFF;">      TempMatRes = TempMatRes - TempMatRKRes; </span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 403</span> <span style="color: #000000; background: #FFFFFF;">      TempMatRes = reshape( TempMatRes, N*N, nVecMax); </span><br/>               <span style="color: #A0A0A0"> 404</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 405</span> <span style="color: #000000; background: #FFFFFF;">      for iVec = 1 : cVec </span><br/><span style="color: #FF0000">  0.01 </span><span style="color: #0000FF">    256 </span><span style="color: #000000; font-weight: bold"> 406</span> <span style="color: #000000; background: #FFFFFF;">	YSourceBlk = floor((arrSourceY(iVec)-1)/nWidthPre) + 1; </span><br/>       <span style="color: #0000FF">    256 </span><span style="color: #000000; font-weight: bold"> 407</span> <span style="color: #000000; background: #FFFFFF;">	XSourceBlk = floor((arrSourceX(iVec)-1)/nWidthPre) + 1; </span><br/>       <span style="color: #0000FF">    256 </span><span style="color: #000000; font-weight: bold"> 408</span> <span style="color: #000000; background: #FFFFFF;">	indSourceBlk = (XSourceBlk-1)*4 + YSourceBlk; </span><br/>       <span style="color: #0000FF">    256 </span><span style="color: #000000; font-weight: bold"> 409</span> <span style="color: #000000; background: #FFFFFF;">	YBlock = mod( arrSourceY(iVec)-1, nWidthPre ) + 1; </span><br/>       <span style="color: #0000FF">    256 </span><span style="color: #000000; font-weight: bold"> 410</span> <span style="color: #000000; background: #FFFFFF;">	XBlock = mod( arrSourceX(iVec)-1, nWidthPre ) + 1; </span><br/>       <span style="color: #0000FF">    256 </span><span style="color: #000000; font-weight: bold"> 411</span> <span style="color: #000000; background: #FFFFFF;">	indBlock = (XBlock-1)*nWidthPre + YBlock; </span><br/><span style="color: #FF0000">  0.01 </span><span style="color: #0000FF">    256 </span><span style="color: #000000; font-weight: bold"> 412</span> <span style="color: #000000; background: #FFFFFF;">	for l = 1 : nBlockCur </span><br/>       <span style="color: #0000FF">   2048 </span><span style="color: #000000; font-weight: bold"> 413</span> <span style="color: #000000; background: #FFFFFF;">	  for k = 1 : nBlockCur </span><br/><span style="color: #FF0000">  0.01 </span><span style="color: #0000FF">  16384 </span><span style="color: #000000; font-weight: bold"> 414</span> <span style="color: #000000; background: #FFFFFF;">	    cDiagBlock = nBlockCur*nBlockCur*(indSourceBlk-1) + ... </span><br/>               <span style="color: #A0A0A0"> 415</span> <span style="color: #000000; background: #FFFFFF;">	      (k-1)*nBlockCur + l;</span><br/><span style="color: #FF0000">  0.31 </span><span style="color: #0000FF">  16384 </span><span style="color: #000000; font-weight: bold"> 416</span> <span style="color: #000000; background: #FFFFFF;">	    DiagBlock{cDiagBlock}.Mat(indBlock, :) = ... </span><br/>               <span style="color: #A0A0A0"> 417</span> <span style="color: #000000; background: #FFFFFF;">	      (TempMatRes(DiagBlock{cDiagBlock}.indTarget, iVec)).';</span><br/><span style="color: #FF0000">  0.03 </span><span style="color: #0000FF">  16384 </span><span style="color: #000000; font-weight: bold"> 418</span> <span style="color: #000000; background: #FFFFFF;">	  end </span><br/>       <span style="color: #0000FF">   2048 </span><span style="color: #000000; font-weight: bold"> 419</span> <span style="color: #000000; background: #FFFFFF;">	end </span><br/>       <span style="color: #0000FF">    256 </span><span style="color: #000000; font-weight: bold"> 420</span> <span style="color: #000000; background: #FFFFFF;">      end </span><br/>               <span style="color: #A0A0A0"> 421</span> <span style="color: #228B22; background: #FFFFFF;">	</span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 422</span> <span style="color: #000000; background: #FFFFFF;">      cVec = 0; </span><br/><span style="color: #FF0000">  0.06 </span><span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 423</span> <span style="color: #000000; background: #FFFFFF;">      TempMatApply = zeros( N, N, nVecMax ); </span><br/><a name="Line424"></a><span style="color: #FF0000">  0.05 </span><span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 424</span> <span style="color: #000000; background: #FFFFFF;">      TempMatRes = zeros(N, N, nVecMax); </span><br/><a name="Line425"></a><span style="color: #FF0000">  0.05 </span><span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 425</span> <span style="color: #000000; background: #FFFFFF;">      TempMatRKRes = zeros(N, N, nVecMax); </span><br/>               <span style="color: #A0A0A0"> 426</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 427</span> <span style="color: #000000; background: #FFFFFF;">    end </span><br/>       <span style="color: #0000FF">     16 </span><span style="color: #000000; font-weight: bold"> 428</span> <span style="color: #000000; background: #FFFFFF;">  end </span><br/>               <span style="color: #A0A0A0"> 429</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>               <span style="color: #A0A0A0"> 430</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>               <span style="color: #A0A0A0"> 431</span> <span style="color: #A0A0A0; background: #FFFFFF;">end</span><br/>               <span style="color: #A0A0A0"> 432</span> <span style="color: #228B22; background: #FFFFFF;"></span><br/>       <span style="color: #0000FF">      1 </span><span style="color: #000000; font-weight: bold"> 433</span> <span style="color: #000000; background: #FFFFFF;">toc </span><br/></pre><p><p>Other subfunctions in this file are not included in this listing.</body></html>